<template>
  <Transition name="fade">
    <div
      class="slide-content-wrapper"
      v-show="menuVisible && settingVisible === 3"
    >
      <Transition name="slide-right">
        <div class="content" v-if="settingVisible === 3">
          <div class="content-page-wrapper" v-if="bookAvailable">
            <!-- 页面内容 -->
            <div class="content-page">
              <KeepAlive>
                <component :is="currentTab === 1 ? content : bookmark">
                </component>
              </KeepAlive>
            </div>

            <!-- 目录底部的选项卡 -->
            <div class="content-page-tab">
              <div
                class="content-page-tab-item"
                :class="{ selected: currentTab === 1 }"
                @click="selectTab(1)"
              >
                {{ $t('book.navigation') }}
              </div>
              <div
                class="content-page-tab-item"
                :class="{ selected: currentTab === 2 }"
                @click="selectTab(2)"
              >
                {{ $t('book.bookmark') }}
              </div>
            </div>
          </div>
          <div class="content-empty" v-else>
            <EbookLoading></EbookLoading>
          </div>
        </div>
      </Transition>

      <!-- 目录右边的留白 -->
      <div class="content-bg" @click="hideTitleAndMenu()"></div>
    </div>
  </Transition>
</template>

<script>
import EbookSlideContents from '@/components/ebook/EbookSlideContents.vue';
import EbookSlideBookmark from './EbookSlideBookmark.vue';
import EbookLoading from '@/components/ebook/EbookLoading.vue';

import { ebookMixin } from '@/utils/mixin';
export default {
  mixins: [ebookMixin],
  components: {
    EbookLoading,
  },
  data() {
    return {
      currentTab: 1,
      content: EbookSlideContents,
      bookmark: EbookSlideBookmark,
    };
  },
  methods: {
    selectTab(tab) {
      this.currentTab = tab;
    },
  },
};
</script>

<style scoped lang="scss">
@import '../../assets/styles/global';
.slide-content-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  z-index: 300;
  .content {
    flex: 0 0 85%;
    width: 85%;
    height: 100%;
    &-page-wrapper {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      .content-page {
        flex: 1;
        width: 100%;
        overflow: hidden;
      }
      .content-page-tab {
        flex: 0 0 px2rem(48);
        width: 100%;
        height: px2rem(48);
        display: flex;

        &-item {
          flex: 1;
          font-size: px2rem(12);
          @include center;
        }
      }
    }

    .content-empty {
      width: 100%;
      height: 100%;
      @include center;
    }
  }
  .content-bg {
    flex: 0 0 15%;
    width: 15%;
    height: 100%;
  }
}
</style>
